//
//  zbdataPickView.m
//  meituan
//
//  Created by apple on 16/5/27.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "zbdataPickView.h"
@interface zbdataPickView()
@property(nonatomic,strong)UIDatePicker *datapick;
@property(nonatomic,strong)UIButton *butten;
@end
@implementation zbdataPickView
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
    }
    return self;
}
-(void)setUpUI
{
    
    self.hidden = YES;
    self.datapick = [[UIDatePicker alloc]init ];
    self.datapick.backgroundColor = [UIColor whiteColor];
    NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
    self.datapick.locale = locale;
    self.datapick.datePickerMode=UIDatePickerModeDate;
    [self addSubview:self.datapick];
    
    UIButton *butten = [[UIButton alloc]init];
    self.butten = butten;
    [self.butten setTitle:@"确定" forState:UIControlStateNormal];

    [butten addTarget:self action:@selector(buttenclic) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:butten];

    
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.datapick.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height-40*Kscr);
    self.butten.frame = CGRectMake(0, self.frame.size.height-40*Kscr, self.frame.size.width, 40*Kscr);
}
-(void)buttenclic
{
    NSDate *selected = [self.datapick date];
    // 创建一个日期格式器
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    // 为日期格式器设置格式字符串
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    // 使用日期格式器格式化日期、时间
    NSString *destDateString = [dateFormatter stringFromDate:selected];
    [self.deleget gavemestr:destDateString];
//    [self removeFromSuperview];
    self.hidden = YES;
}
-(void)dataViewShow
{
    self.hidden = NO;
}
-(void)dataviewhiden
{
    self.hidden = YES;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
